﻿
namespace Game.Global.GameCenter
{
    /// <summary>
    /// 成就点数的Data
    /// </summary>
    public struct AchievementData
    {
        /// <summary>
        /// 成就的ID，用于上传到对应服务器上
        /// </summary>
        public string AchievementId { get; set; }

        /// <summary>
        /// 当前成就进度
        /// </summary>
        public int CurrAchiPoints { get; set; }

        /// <summary>
        /// 需要的成就点数
        /// </summary>
        public int AchieveRequired { get; set; }

        /// <summary>
        /// 是否已经达成成就
        /// </summary>
        public bool IsAchieved
        {
            get
            {
                return CurrAchiPoints >= AchieveRequired;
            }
        }

        /// <summary>
        /// 增加成就点数，如果满足成就要求，则返回true
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public bool AddAchiPointGot(int val)
        {
            CurrAchiPoints += val;
            if (CurrAchiPoints >= AchieveRequired
                && IsAchieved == false)
            {
                CurrAchiPoints = AchieveRequired;
                return true;
            }
            else
            {
                return false;
            }
        }

    }
}